package cn.com.open.ms.ecgpaasdatarest.utils;

import org.apache.commons.lang.CharSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.propertyeditors.CharacterEditor;
import org.springframework.http.HttpStatus;

import javax.servlet.http.HttpServletResponse;

public class HtmlUtil {

	private static final Logger LOG = LoggerFactory.getLogger(HtmlUtil.class);

	private HtmlUtil() {}

	public static void writeJson(HttpServletResponse response, Object message, HttpStatus status) {
		try {
			response.setHeader("Content-type", "application/json;charset=UTF-8");
			response.setHeader("Access-Control-Allow-Origin", "*");
			response.setCharacterEncoding("UTF-8");
			response.setStatus(status.value());
			response.getWriter().write(GsonUtil.toJson(message));
		} catch (Exception e){
			LOG.error(e.getMessage());
		}

	}

}
